import request from '@/utils/request'

// 得到员工列表信息
export const getEmployList = (obj) => {
  const { page, pagesize, keyword, departmentId } = obj
  return request.get('/sys/user', {
    params: {
      page,
      pagesize,
      keyword,
      departmentId
    }
  })
}

// 导出员工信息模版
export const exportEmployee = () => {
  return request.get('/sys/user/export', {
    responseType: 'blob'
  })
}

// 下载模版
export const getTemplate = () => {
  return request.get('/sys/user/import/template', {
    responseType: 'blob'
  })
}

// 处理上传
export const handleUpLoad = (data) => {
  return request.post('/sys/user/import', data)
}

// 删除员工
export const employeeDelete = (id) => {
  return request.delete(`/sys/user/${id}`)
}

// 新增员工
export const addEmployee = (obj) => {
  return request.post('/sys/user', {
    ...obj
  })
}

// 获取员工信息
export const getEmployeeDetail = (id) => {
  return request.get(`/sys/user/${id}`)
}

// 编辑员工信息
export const setEmployeeDetail = (obj) => {
  return request.put(`/sys/user/${obj.id}`, {
    ...obj
  })
}

// 拿到员工角色信息
export const getEnableList = () => {
  return request.get('/sys/role/list/enabled')
}

// 给员工分配角色
export const setRolePermission = (data) => {
  return request.put('/sys/user/assignRoles', data)
}
